package com.mass.core.sys.menu.controller;


import com.mass.core.framework.aop.LogAop;
import com.mass.core.sys.menu.model.SysMenu;
import com.mass.core.sys.menu.services.SysMenuServices;
import com.mass.core.utils.AjaxResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/sysMenu")
public class SysMenuController {

    @Autowired
    private SysMenuServices sysMenuServices;

    @RequestMapping("/findSysMenu")
    public AjaxResponse findSysMenu(Long id) {
        return sysMenuServices.findSysMenu(id);
    }

    @LogAop(menuName = "菜单管理", operationDesc = "查询树形菜单")
    @RequestMapping("/findSysMenuAll")
    public AjaxResponse findSysMenuAll() {
        return AjaxResponse.success(sysMenuServices.findAll());
    }

    /**
     * @param sysMenu
     * @param page
     * @param limit
     * @return AjaxResponse 返回类型
     * @throws
     * @Title: selectSysMenuPage
     * @Description: 分页查询菜单
     */
    @LogAop(menuName = "菜单管理", operationDesc = "分页查询菜单")
    @RequestMapping("/selectSysMenuPage")
    public AjaxResponse selectSysMenuPage(SysMenu sysMenu, Integer page,
                                          Integer limit) {
        return sysMenuServices.selectSysMenuPage(sysMenu, page, limit);
    }

    /**
     * 添加
     *
     * @param sysMenu
     * @param session
     * @return
     */
    @LogAop(menuName = "菜单管理", operationDesc = "添加菜单")
    @RequestMapping("/insertSysMenu")
    public AjaxResponse insertSysMenu(SysMenu sysMenu, HttpSession session) {
        return sysMenuServices.insertSysMenu(sysMenu, session);
    }

    /**
     * 修改
     *
     * @param sysMenu
     * @return
     * @Param moveType 移动位置
     */
    @LogAop(menuName = "菜单管理", operationDesc = "修改菜单")
    @RequestMapping("/updateSysMenu")
    public AjaxResponse updateSysMenu(SysMenu sysMenu, String moveType) {
        return sysMenuServices.updateSysMenu(sysMenu, moveType);
    }
}
